package com.example.informationEntry.service.impl;

import com.example.informationEntry.dao.NaDormitoryInformationDao;
import com.example.informationEntry.entity.NaDormitoryInformation;
import com.example.informationEntry.service.NaDormitoryInformationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 宿舍信息表(NaDormitoryInformation)表服务实现类
 *
 * @author makejava
 * @since 2019-04-08 11:20:34
 */
@Service("naDormitoryInformationService")
public class NaDormitoryInformationServiceImpl implements NaDormitoryInformationService {
    @Resource
    private NaDormitoryInformationDao naDormitoryInformationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param dormitoryNumber 主键
     * @return 实例对象
     */
    @Override
    public NaDormitoryInformation queryById(String dormitoryNumber) {
        return this.naDormitoryInformationDao.queryById(dormitoryNumber);
    }

    /**
     * 查询多条数据
     *
     * @param dormitoryNumber 宿舍号
     * @return 对象列表
     */
    @Override
    public int queryAllCount(String dormitoryNumber) {
        return this.naDormitoryInformationDao.queryAllCount(dormitoryNumber);
    }

    /**
     * 查询多条数据
     *
     * @param naDormitoryInformation 实例对象
     * @return list集合
     */
    @Override
    public List<NaDormitoryInformation> queryAll(NaDormitoryInformation naDormitoryInformation){
        return this.naDormitoryInformationDao.queryAll(naDormitoryInformation);
    }

    /**
     * 新增数据
     *
     * @param naDormitoryInformation 实例对象
     * @return 实例对象
     */
    @Override
    public NaDormitoryInformation insert(NaDormitoryInformation naDormitoryInformation) {
        this.naDormitoryInformationDao.insert(naDormitoryInformation);
        return naDormitoryInformation;
    }

    /**
     * 修改数据
     *
     * @param naDormitoryInformation 实例对象
     * @return 实例对象
     */
    @Override
    public NaDormitoryInformation update(NaDormitoryInformation naDormitoryInformation) {
        this.naDormitoryInformationDao.update(naDormitoryInformation);
        return this.queryById(naDormitoryInformation.getDormitoryNumber());
    }

    /**
     * 通过主键删除数据
     *
     * @param dormitoryNumber 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String dormitoryNumber) {
        return this.naDormitoryInformationDao.deleteById(dormitoryNumber) > 0;
    }
}